package com.wj;

import java.sql.*;

public class ReadAllTables {
    public static void main(String[] args) {
        String url="jdbc:mysql://localhost:3306/yeb?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
        String username="root";
        String password="963.";
        String database="yeb";
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            Connection connection = DriverManager.getConnection(url, username, password);
            PreparedStatement ps = connection.prepareStatement("show tables from "+database);
            ResultSet res = ps.executeQuery();

            String str="";
            while (res.next() == true){
                str+=res.getString(1)+",";
            }
            System.out.println(str.substring(0,str.length()-1));
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
